package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.PersonBase.WormBean;
import com.project.service.IWormService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("worm")
public class WormController {

    @Resource
    private IWormService wormService;


    @RequestMapping("findWorm")
    public IPage<WormBean> findWorm(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo,@RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String wormName, String wormHost){


      IPage<WormBean> page =  wormService.findWorm(pageNo,pageSize,wormName,wormHost);

      System.out.println(pageNo);


      return page;

    }


    @RequestMapping("addWorm")
   public String addWorm(WormBean wormBean){


        if (wormBean != null) {
            wormService.addWorm(wormBean);
        }
        return "ok";
    }

    @RequestMapping("findWormById")
    public WormBean findWormById(int wormId){

        WormBean wormBean = wormService.findWormById(wormId);


        return wormBean;
    }


}
